package totoCharts;
import guestbook.abstractRequestServlet;
import javax.servlet.http.*;
import java.util.List;


//this class exists in order to set the wave ID to 0
public class newWaveIDServlet extends abstractRequestServlet<globalWaveID>
{    
	/**
	 * 
	 */
	private static final long serialVersionUID = -6791775649571616985L;

	public void doGet(HttpServletRequest req, HttpServletResponse resp)
	 
	{
		try
		{
			List<globalWaveID> list;
			String result="error";
			list=getData(globalWaveID.class);
	    
		    //if we already have a waveID object in the DB
		    if (list.size()>0){
		    
		    	for (globalWaveID ID : list) {
		    		ID.setWaveID(0);
		    		result="success";
		    	}
		    
		    }
		    else //if we don't have a waveID object in the DB, create a new one
		    {
		    	globalWaveID ID=new globalWaveID();
		    	guestbook.DBMethods.saveInDB(ID, true);
		    	result="success";
		    }
		    
		    writeToServlet(resp,result);
		    
		}
		catch (Exception e) /* catches exception for the gadget*/
		{
			e.printStackTrace();
		} 
		finally
		{
			pmClose();
		}
			    
	}
}



